<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Iterator"%>
<%@ page import="org.limp.mine.StringTool"%> 
<%@ page import="org.limp.mine.Label"%>
<%@ page import="org.limp.mine.Controller"%>	
<%@ page import="org.limp.mine.DateTrimmer"%>
<% 
    String context = jt.classic.system.ISystem.getContextPath();
	Object[] result = (Object[])request.getAttribute("result");	
	Label label = (Label)result[1];
	Controller controller = (Controller)result[2];	
	String pageNO = (String)result[3];
	List resultList = (List) result[0];
	
	String v_jsy_xm = (String)request.getAttribute("v_jsy_xm");//姓名
	String v_jsy_dw = (String)request.getAttribute("v_jsy_dw");//单位
	
	String index = (String)request.getAttribute("index");//动态添加车辆序号
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<jsp:include page="../../head.jsp"></jsp:include> 
<script language="javascript">
  var chk = false;
  function checkall(thizz){
    var chks = document.getElementsByTagName("input");
    for(var i=0;i<chks.length;i++){
      if(chks[i].type == "checkbox"){
        chks[i].checked = !chk;
      }
    }
    
    chk = !chk;
  }
  
  function handleDelete(){
    var rnt = false;
    var ids = "";
    var chks = document.getElementsByTagName("input");
    for(var i=0;i<chks.length;i++){
      if(chks[i].type == "checkbox" && chks[i].checked){
        rnt = true;
        ids += chks[i].value + ",";
      }
    }
    
    if(!rnt){
      alert("请选择要删除的驾驶员");
    }else if(confirm("确定删除")){
      createHidden("ids",ids.substring(0,ids.length - 1));
      document.form1.action = "<%=context%>/app/jsy.do?method=delete";
      document.form1.submit();
    }
  }
  
  function handleQuery(){
    document.form1.action = context + "/app/jsy.do?method=list&type=select&index=<%=index%>";
    document.form1.submit();
  }
  
  function handleInsert(){
      var url = "<%=context%>/app/jsy.do?method=neu";
      window.location.href = url;
  }
  
  function handleEdit(id){
      var url = "<%=context%>/app/jsy.do?method=edit&id=" + id;
      window.location.href = url;
  }  
   
  function handleReresh(){
      window.location.href = context + "/app/jsy.do?method=list&pageNO=<%=pageNO%>&type=select&index=<%=index%>";
  }
  /**
  * 添加驾驶员
  */
  function handleSelect(){
  var rnt = false;
    var ids = "";
    var names = "";
    var chks = document.getElementsByTagName("input");
    for(var i=0;i<chks.length;i++){
      if(chks[i].type == "radio" && chks[i].checked&&chks[i].value!=""){
        rnt = true;
        ids += chks[i].value;
        
        names += document.getElementById(chks[i].value).value;
        break;
      }
    }
   
    if(ids!=""){
    	addobj(ids,names,document.getElementById("index").value);
    	parent.closeDialog();
    }else{
       alert("请选择驾驶员！");
    }
  }
  
   /**
   *向父窗口添加驾驶员
   */
    function addobj(id,name,index){
     var jsy_id = window.parent.document.getElementById("jsy_id"+index);
     var jsy_name = window.parent.document.getElementById("jsy_name"+index);
     jsy_id.value = id;
     jsy_name.value = name;
     } 
</script>
<body>
<form name="form1" method="post" action="">
<input type="hidden" name="pageNO" value="<%=pageNO%>">
<input type="hidden" name="index" id="index" value="<%=index%>" />
<h2>驾驶员列表</h2>
<table class="tab" border="0" width="98%" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="8" align="right">
       驾驶员姓名 <input type="text" class="box3" name="v_jsy_xm" value="<%=v_jsy_xm%>">
       单位 <input type="text" class="box3" name="v_jsy_dw" value="<%=v_jsy_dw%>">
      <input type="button" class="button0" value=" 查 询 " onclick="javascript:handleQuery();">
      <input type="button" class="button0" value=" 确 定 " onclick="javascript:handleSelect();"> 
    </td>
  </tr>
  <tr>
    <td colspan="8"></td>
  </tr>
  <tr class="tr0" bgcolor="#A7CADE"> 
    <td class="td0" background="<%=context%>/app/images/bg_lm.jpg" title="全部选择/取消选择" onclick="javascript:checkall();" width="10" align="center">&nbsp;</td>
    <td class="td0" background="<%=context%>/app/images/bg_lm.jpg" width="20%">&nbsp;驾驶员姓名</td>
    <td class="td0" background="<%=context%>/app/images/bg_lm.jpg" width="40%">&nbsp;单位</td>
    <td class="td0" background="<%=context%>/app/images/bg_lm.jpg" width="10%">&nbsp;性别</td>
    <td class="td0" background="<%=context%>/app/images/bg_lm.jpg" width="20%">&nbsp;准驾车类</td>
  </tr>
  <% 
    if(resultList!=null&&!resultList.isEmpty()){
    
       for(int i=0;i<resultList.size();i++){
	       Map info = (Map)resultList.get(i);
	       String number = (String)info.get("PAGINATION_NUMBER");
	       
			String jsy_id = StringTool.checkString(info.get("JSY_ID"));// ID
			String jsy_dw = StringTool.checkString(info.get("JSY_DW"));//单位
			String jsy_xm = StringTool.checkString(info.get("JSY_XM"));//姓名
			String jsy_xb = StringTool.checkString(info.get("JSY_XB"));//性别
			String jsy_csny = StringTool.checkString(info.get("JSY_CSNY"));//出生年月
			String jsy_sfzh = StringTool.checkString(info.get("JSY_SFZH"));//身份证号
			String jsy_jszh = StringTool.checkString(info.get("JSY_JSZH"));//驾驶证号
			String jsy_zjcl = StringTool.checkString(info.get("JSY_ZJCL"));//准驾车类
			String jsy_clzrq = StringTool.checkString(info.get("JSY_CLZRQ"));//初领证日期
			String jsy_jszyxny = StringTool.checkString(info.get("JSY_JSZYXNY"));//驾驶证有效年月
			String jsy_glkyxq = StringTool.checkString(info.get("JSY_GLKYXQ"));//管理卡有效期
			String jsy_xcsyrq = StringTool.checkString(info.get("JSY_XCSYRQ"));//下次审验日期
			String jsy_jtdz = StringTool.checkString(info.get("JSY_JTDZ"));//家庭地址
			        
  %> 
  <tr onMouseOver="javascript:this.bgColor='#ffff99'" onmouseout=" javascript:this.bgColor='#F5F7F9'" bgColor="#F5F7F9"> 
    
    <td class="td1" align="center">
    <input type="radio" name=chk id="chk_<%=jsy_id%>" value="<%=jsy_id%>"  />
    <input type=hidden id="<%=jsy_id%>" value="<%=jsy_xm%>" />
    </td>
    <td class="td1">&nbsp;<a href="javascript:void(0);" onclick="javascript:handleEdit('<%=jsy_id%>');"><%=jsy_xm%></a></td>
    <td class="td1">&nbsp;<%=jsy_dw%></td>
    <td class="td1">&nbsp;<%=jsy_xb.equals("1")?"男":"女"%></td>
    <td class="td1">&nbsp;<%=jsy_zjcl%></td>
  </tr>
  <%
        }
     }
  %>
</table> 
<table width="98%" class="tab-noborder" border="0" cellspacing="0" cellpadding="0">
  <tr>
   <td>
    <%=label.displayLabel()%>
   </td>
   <td align="right">
        <%=label.startLabel()%>
        <%=label.previousLabel()%>
        <%=label.nextLabel()%>
        <%=label.endLabel()%>
        <%=controller.getController().toString()%>
    </td>
  </tr>
</table>  
<%=controller.getControlScript(true)%> 
</form>
</body>
</html>	